Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[act] flush suspense fallbacks in tests #16240

Merged

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented Jul 29, 2019

Opening this to share the approach andrew et al, and answer some pending questions.

In this PR, for tests (specifically, code inside an act() scope), we immediately trigger work that would have otherwise required a timeout. This makes it simpler to tests loading/spinner states, and makes tests resilient to changes in React.

For some of our tests(specifically, ReactSuspenseWithNoopRenderer-test.internal), we don't want fallbacks to immediately trigger, because we're testing intermediate states and such. Added a feature flag flushSuspenseFallbacksInTests to disable this behaviour on a per case basis.

Open questions -

  • should react warn you if you try to suspend outside an act scope?

@sizebot
Copy link

sizebot commented Jul 29, 2019

Details of bundled changes.

Comparing: e6a0473...ad9b407

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 643.87 KB 644.5 KB 140.46 KB 140.62 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 0.0% 102.49 KB 102.54 KB 31.25 KB 31.26 KB UMD_PROD
react-art.development.js +0.1% +0.1% 574.75 KB 575.38 KB 123.17 KB 123.32 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 67.53 KB 67.59 KB 20.6 KB 20.62 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 588.74 KB 589.27 KB 122.77 KB 122.87 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 220.49 KB 220.64 KB 37.6 KB 37.65 KB FB_WWW_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 115.23 KB 115.28 KB 36.25 KB 36.27 KB NODE_PROFILING
react-dom-server.browser.development.js +0.1% +0.2% 136.79 KB 136.93 KB 36.14 KB 36.2 KB UMD_DEV
ReactDOM-dev.js +0.1% +0.1% 931.75 KB 932.29 KB 206.14 KB 206.25 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.78 KB 3.78 KB 1.52 KB 1.52 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 11.19 KB 11.19 KB 4.11 KB 4.11 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.21 KB 1.21 KB 705 B 707 B UMD_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 10.97 KB 10.97 KB 4.04 KB 4.04 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.05 KB 1.05 KB 636 B 637 B NODE_PROD
react-dom.development.js +0.1% +0.1% 908.23 KB 908.86 KB 205.76 KB 205.94 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 111.52 KB 111.56 KB 35.81 KB 35.81 KB UMD_PROD
react-dom.profiling.min.js 0.0% +0.1% 114.96 KB 115.01 KB 36.83 KB 36.88 KB UMD_PROFILING
react-dom.development.js +0.1% +0.1% 902.53 KB 903.16 KB 204.28 KB 204.46 KB NODE_DEV
react-dom-server.node.development.js +0.1% +0.1% 134.85 KB 134.99 KB 35.76 KB 35.8 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 111.57 KB 111.62 KB 35.3 KB 35.32 KB NODE_PROD
ReactDOM-prod.js 0.0% 🔺+0.1% 372.71 KB 372.87 KB 68.49 KB 68.53 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% +0.1% 377.61 KB 377.77 KB 69.56 KB 69.62 KB FB_WWW_PROFILING
react-dom-server.browser.development.js +0.1% +0.1% 132.92 KB 133.06 KB 35.22 KB 35.27 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 135.09 KB 135.09 KB 34.66 KB 34.66 KB FB_WWW_DEV
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.85 KB 3.85 KB 1.5 KB 1.5 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.1 KB 1.1 KB 667 B 668 B NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 599.73 KB 600.26 KB 125.22 KB 125.33 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 39.37 KB 39.37 KB 9.92 KB 9.92 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.62 KB 11.62 KB 3.55 KB 3.55 KB UMD_PROD
react-test-renderer-shallow.production.min.js 0.0% -0.0% 11.77 KB 11.77 KB 3.67 KB 3.67 KB NODE_PROD
react-test-renderer.development.js +0.1% +0.1% 587.8 KB 588.3 KB 125.81 KB 125.91 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 69.04 KB 69.14 KB 21.1 KB 21.14 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 583.34 KB 583.84 KB 124.69 KB 124.79 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 68.79 KB 68.89 KB 20.9 KB 20.93 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.2% 572.83 KB 573.46 KB 121.7 KB 121.89 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 68.75 KB 68.79 KB 20.44 KB 20.45 KB NODE_PROD
react-reconciler-reflection.development.js 0.0% 0.0% 16.63 KB 16.63 KB 5.16 KB 5.16 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.59 KB 2.59 KB 1.14 KB 1.14 KB NODE_PROD
react-reconciler-persistent.development.js +0.1% +0.1% 569.98 KB 570.48 KB 120.49 KB 120.62 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.1% 🔺+0.1% 68.76 KB 68.8 KB 20.44 KB 20.45 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 271.99 KB 272.15 KB 46.7 KB 46.74 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 280.57 KB 280.73 KB 48.27 KB 48.32 KB RN_OSS_PROFILING
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 265.67 KB 265.82 KB 45.74 KB 45.78 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 274.53 KB 274.69 KB 47.24 KB 47.29 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 735.47 KB 736 KB 155.49 KB 155.59 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 265.67 KB 265.83 KB 45.75 KB 45.79 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% +0.1% 722.76 KB 723.29 KB 153.04 KB 153.14 KB RN_OSS_DEV
ReactFabric-profiling.js +0.1% +0.1% 274.53 KB 274.69 KB 47.25 KB 47.29 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 722.85 KB 723.38 KB 153.08 KB 153.18 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 271.99 KB 272.14 KB 46.71 KB 46.75 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 280.56 KB 280.72 KB 48.28 KB 48.32 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 735.37 KB 735.9 KB 155.45 KB 155.55 KB RN_OSS_DEV

Generated by 🚫 dangerJS

@threepointone threepointone requested a review from acdlite July 29, 2019 15:28
@threepointone threepointone force-pushed the flush-suspense-fallbacks branch from b6a9cd4 to f6eb32d Compare July 30, 2019 08:42
@threepointone
Copy link
Contributor Author

threepointone commented Jul 30, 2019

I've updated the PR, but I do want to add at least a few tests (even if just a few) that just verify that this works in product-like code. will do before eod. EDIT: done.

@threepointone threepointone force-pushed the flush-suspense-fallbacks branch 2 times, most recently from 322b17b to e117bcb Compare July 30, 2019 09:54
@threepointone threepointone changed the title RFC - [act] flush suspense fallbacks in tests [act] flush suspense fallbacks in tests Jul 30, 2019
@threepointone threepointone force-pushed the flush-suspense-fallbacks branch 3 times, most recently from e27af9c to d3108b0 Compare July 30, 2019 11:46
@threepointone threepointone requested a review from acdlite July 30, 2019 11:47
@threepointone threepointone force-pushed the flush-suspense-fallbacks branch from d3108b0 to b7eeca7 Compare July 30, 2019 17:30
In this PR, for tests (specifically, code inside an `act()` scope), we immediately trigger work that would have otherwise required a timeout. This makes it simpler to tests loading/spinner states, and makes tests resilient to changes in React.

For some of our tests(specifically, ReactSuspenseWithNoopRenderer-test.internal), we _don't_ want fallbacks to immediately trigger, because we're testing intermediate states and such. Added a feature flag `flushSuspenseFallbacksInTests` to disable this behaviour on a per case basis.
@threepointone threepointone force-pushed the flush-suspense-fallbacks branch from b7eeca7 to ad9b407 Compare July 30, 2019 18:05
@threepointone threepointone merged commit db3ae32 into facebook:master Jul 30, 2019
@threepointone threepointone deleted the flush-suspense-fallbacks branch July 30, 2019 18:12
acdlite added a commit to acdlite/react that referenced this pull request Jul 31, 2019
So that it doesn't leak into the production bundle. Follow-up to facebook#16240.
acdlite added a commit that referenced this pull request Jul 31, 2019
* [act] Wrap IsThisRendererActing in DEV check

So that it doesn't leak into the production bundle. Follow-up to #16240.

* Disable Suspense fallback test in prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants